import Route from 'react-router/lib/Route'
import Home from "./components/Home.js"
import CalView from "./components/calview/CalView"
import RoomPlan from "./components/roomPlan/RoomPlan"
import Search from "./components/Search.js"
import Decision from "./components/Decision.js"
import Repeat from "./components/repeat/Repeat"
import Report from "./components/report/Report"
import Screen from "./components/screen.js"
import MeetingDialog from './public/dialog/index.js'
import RoomPlanDialog from './public/roomPlan/index.js'
import RoomUsedReport from "./components/RoomUsedReport.js"
import MeetingReport from "./components/MeetingReport.js";
import DialogSingle from './public/DialogSingle';
import Monitor from './components/Monitor';

import './style/index';
import base from './public/util/base';
import {WeaLocaleProvider} from 'ecCom'
import store from './stores/index';
import {Provider} from 'mobx-react';
require('./public/util/PcInterface')

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'meeting');
const { getLocaleLabelByCode } = WeaLocaleProvider;

const MeetingRoute = (
  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@r83kcv`} name="meeting" breadcrumbName="会议" path="meeting" component={Home} onEnter={getLocaleLabel}>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@a51x7k`} name="calView" breadcrumbName="会议日历" path="calView" component={CalView}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@qjf407`} name="roomPlan" breadcrumbName="会议室使用情况" path="roomPlan" component={RoomPlan}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@q2p9sd`} name="search" breadcrumbName="查询会议" path="search" component={Search}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@83hdbc`} name="decision" breadcrumbName="会议任务" path="decision" component={Decision}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@hof3o4`} name="repeat" breadcrumbName="周期会议" path="repeat" component={Repeat}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@qqevdr`} name="report" breadcrumbName="会议报表" path="report" component={Report}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@2dtqti`} name="screen" breadcrumbName="签到投屏"
           path="screen/:meetingid/:bgcolor/:fontcolor/:showdep/:showhead/:shownum/:showsub/:fontsize/:bgimg/:showtitle"
           component={Screen}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@umobwl`} name="screen" breadcrumbName="签到投屏" path="screen/:meetingid" component={Screen}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@fmy27c`} name="monitor" breadcrumbName="会议监控" path="monitor" component={Monitor}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@gu8u47`} name="report" breadcrumbName="会议室使用次数统计" path="roomUsedReport" component={RoomUsedReport}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@1mj9z7`} name="meetingReport" breadcrumbName="年度会议统计表" path="meetingReport" component={MeetingReport}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@v5vsex`} name="dialogsingle" breadcrumbName="新建、查看会议单页" path="dialogsingle" component={DialogSingle}/>
  </Route>
)

class MeetingCreateProvider extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      reRender: false,
    };
  }
  componentDidMount() {
    // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
    getLocaleLabelByCode('meeting').then(() => this.setState({ reRender: true }));
  }

  render() {
    return <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@hlc13g`}  {...store}><MeetingDialog ecId={`${this && this.props && this.props.ecId || ''}_MeetingDialog@8zkx41`} {...this.props} /></Provider>
  }
}

class MeetingRoomPlanProvider extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      reRender: false,
    };
  }
  componentDidMount() {
    // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
    getLocaleLabelByCode('meeting').then(() => this.setState({ reRender: true }));
  }

  render() {
    return <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@1st7sq`} {...store}><RoomPlanDialog ecId={`${this && this.props && this.props.ecId || ''}_RoomPlanDialog@6xinj2`} {...this.props}  /></Provider>
  }
}

// class PreviewMeetingDialog extends React.Component {
//   render(){
//     const { isCustom=false } = this.props;
//     if(isCustom) return <Provider  {...store}><DialogSingle {...this.props} /></Provider>
//     return <DialogSingle {...this.props}/>
//   }
// }

module.exports = {
  Route: MeetingRoute,
  store: store,
  com: {
    MeetingDialog: MeetingCreateProvider,
    MeetingRoomPlan: MeetingRoomPlanProvider,
    // PreviewMeeting: PreviewMeetingDialog,
  }
}

window.weaMeeting=module.exports;
